<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <style>
      .active {
        color: red;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <ul>
        <li
          v-for="(item,index) in movies"
          :class="{active:currrentIndex===index}"
          @click="doclick(index)"
        >
          {{item}}
        </li>
      </ul>
    </div>

    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          movies: ['三国', '水浒', '西游记', '红楼梦'],
          currrentIndex: 0
        },
        methods: {
          doclick(index) {
            this.currrentIndex = index
          }
        }
      })
    </script>
  </body>
</html>
